package adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.itboye.hutoubenjg.R;

import java.util.List;

import base.MyApplcation;
import bean.messge_bean.SystemMessgeBean;
import util.utls.Const;
import util.utls.TimeFormat;
import util.utls.XImageLoader;
import widget.RoundImageView;


/**
 * 帖子消息列表
 */
public class TieZiMessageAdapter extends android.widget.BaseAdapter {
    Context context;
    List<SystemMessgeBean.ListEntity> been;
    public TieZiMessageAdapter(Context context, List<SystemMessgeBean.ListEntity> been){
        this.context=context;
        this.been=been;
    }

    @Override
    public int getCount() {
        return been.size();
    }

    @Override
    public Object getItem(int position) {
        return been.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHoudr houdr;
        if(convertView==null){
            houdr=new ViewHoudr();
            convertView= LayoutInflater.from(MyApplcation.ctx).inflate(R.layout.item_messges_tiezi,null);
            houdr.mess_title = (TextView) convertView.findViewById(R.id.mess_title);
            houdr.mess_time = (TextView) convertView.findViewById(R.id.mess_time);
            houdr.mess_time_content = (TextView) convertView.findViewById(R.id.mess_time_content);
            houdr.mess_content = (TextView) convertView.findViewById(R.id.mess_content);
            houdr.mess_img = (RoundImageView) convertView.findViewById(R.id.mess_img);
            convertView.setTag(houdr);
        }else{
            houdr= (ViewHoudr) convertView.getTag();
        }

        XImageLoader.load(Const.IMAGE_HEAD_TWO + been.get(position).getFrom_id(), houdr.mess_img);
        houdr.mess_title.setText(been.get(position).getFrom_name());
        houdr.mess_time.setText(TimeFormat.DateFormat(been.get(position).getCreate_time()));
        houdr.mess_time_content.setText(been.get(position).getPost_content());
        houdr.mess_content.setText(been.get(position).getContent());
        return convertView;
    }
    private class ViewHoudr{

        RoundImageView mess_img;
        TextView mess_title,mess_time,mess_time_content,mess_content;
    }

}
